package com.rao.quartz.controller;

import com.rao.domain.inputPojo.InfoGoodsInput;
import com.rao.entity.InfoGoods;
import com.rao.entity.UserGoods;
import com.rao.quartz.service.serviceImpl.InfoGoodsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: raoguang
 * @Date: 2022/05/28/22:24
 * @Description:
 */
@RestController
public class infoGoodsController {

    @Autowired
    private InfoGoodsServiceImpl infoGoodsService;

    @GetMapping("/getAllGoodsInfo")
    public List<InfoGoods> getAllGoodsInfo() {
        List<InfoGoods> allGoodsInfo = infoGoodsService.getAllGoodsInfo();
        if (allGoodsInfo != null) {
            return allGoodsInfo;
        }
        return null;
    }

    @GetMapping("/getUserGoodsInfo/{memId}")
    public UserGoods getUserGoodsInfo(@PathVariable("memId") String userId) {
        UserGoods userGoodsInfo = infoGoodsService.getUserGoodsInfo(userId);
        return userGoodsInfo;
    }

    @GetMapping("/getOneGoodsInfo/{gdsId}")
    public InfoGoods getOneGoodsInfo(@PathVariable("gdsId") String goodsId) {
        InfoGoods oneGoodsInfo = infoGoodsService.getOneGoodsInfo(goodsId);
        return oneGoodsInfo;
    }

    @PostMapping("/insertGoodsInfo")
    public boolean insertGoodsInfo(@RequestBody InfoGoodsInput oneGood) {
        boolean ifSuccess = infoGoodsService.insertGoodsInfo(oneGood.infoGoods);
        return ifSuccess;
    }

}
